package com.hyl.crmclient.config;

import com.hyl.crmclient.intercept.LoginIntercept;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description 拦截器
 * @Author hyl
 * @Date 2022/5/31 16:22
 **/
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
	//private String[] excludePathPatterns; //不包含

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		String[] pathPatterns = {"/main","/user/*"}; //拦截路径规则
		String[] excludePathPatterns = {"/login","/regist","/tologin","/reg","/statics/**"}; //排除路径规则
		registry.addInterceptor(new LoginIntercept())//添加自定义拦截器
				.addPathPatterns(pathPatterns)
				.excludePathPatterns(excludePathPatterns)
				.order(2);
	}

}
